﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StockFileByUsername.aspx.cs" Inherits="GPSTrackingWebsiteManager.Manager.Pages.StockFileByUsername" %>

<%@ Register Src="~/Manager/UserControls/StockFileSearch.ascx" TagPrefix="uc1" TagName="StockFileSearch" %>


<!DOCTYPE html>

<link href="../../Css/GPSTrackingWebsite.css" rel="stylesheet" />
<link href="../../Css/messi.css" rel="stylesheet" />
<script src="../../Javascript/jquery-1.11.1.min.js"></script>
<script src="../../Javascript/messi.js"></script>
<script src="../../Javascript/Custom.js"></script>
<script src="../../Javascript/WindowMessageManager.js"></script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Archivos por usuario</title>
    <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
        <script type="text/javascript">
            function resizeGrid() {
                var height = (window.innerHeight);

                var tableView = $find("<%=UsersGrid.ClientID %>");
            tableView.get_element().style.height = (height) / 2 + "px";

            var tableView2 = $find("<%=StockFileGrid.ClientID %>");
            tableView2.get_element().style.height = (height) / 2 + "px";

            document.getElementById('HiddenFieldHeight').value = (height);
        }

        //Windows Message Manager 
        var objWindowsMessageManager = new WindowsMessageManager();
        </script>
    </telerik:RadScriptBlock>
</head>
<body onresize="resizeGrid()" style="overflow: hidden">
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="UsersGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="HiddenFieldError" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="UsersGrid" />
                        <telerik:AjaxUpdatedControl ControlID="StockFileGrid" UpdatePanelCssClass="" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="StockFileGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="StockFileGrid" UpdatePanelCssClass="" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnStockFileOK">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="StockFileGrid" UpdatePanelCssClass="" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>
        <asp:HiddenField ID="HiddenFieldHeight" runat="server" Value="500" />
        <asp:HiddenField ID="HiddenFieldError" runat="server" Value="" />
        <telerik:RadGrid ID="UsersGrid" runat="server" AllowFilteringByColumn="False" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Height="100%" Width="100%" GroupingSettings-CaseSensitive="false" AllowSorting="true" OnNeedDataSource="UsersGrid_NeedDataSource" OnSelectedIndexChanged="UsersGrid_SelectedIndexChanged">
            <MasterTableView EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-CaptionFormatString="Modo Edición" CommandItemDisplay="TopAndBottom" NoMasterRecordsText="No hay registros" AllowFilteringByColumn="true" TableLayout="Auto">
                <CommandItemTemplate>
                    <div style="padding: 5px 5px;">
                        Lista de Usuarios: 
                                    <asp:LinkButton ID="lbClearFilters" runat="server" OnClick="lbClearFiltersUsersGrid_Click" Visible='<%# !UsersGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/mixx-icon.png"/>Limpiar Filtros</asp:LinkButton>
                        <asp:LinkButton ID="lbShowError" runat="server" OnClick="lbShowError_Click" Visible='<%# HiddenFieldError.Value == string.Empty ? false : true %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/bug-icon.png"/>Error Técnico</asp:LinkButton>
                    </div>
                </CommandItemTemplate>

                <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                    <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>

                <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>

                <Columns>                    
                    <telerik:GridBoundColumn DataField="Username" HeaderText="Username" UniqueName="Username" ForceExtractValue="Always" MaxLength="30" FilterControlWidth="80px" CurrentFilterFunction="EqualTo" ShowFilterIcon="false" ItemStyle-Width="10px" AutoPostBackOnFilter="true" HeaderStyle-Width="100px" FilterControlAltText="Filter Username column">
                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                            <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Password" HeaderText="Password" UniqueName="Password" ForceExtractValue="Always" Display="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Identification" MaxLength="16" FilterControlWidth="90px" CurrentFilterFunction="Contains" ShowFilterIcon="false" ItemStyle-Width="10px" AutoPostBackOnFilter="true" HeaderStyle-Width="105px" HeaderText="Identificación" UniqueName="Identification">
                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                            <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Name" MaxLength="50" FilterControlWidth="80px" CurrentFilterFunction="Contains" ShowFilterIcon="false" ItemStyle-Width="10px" AutoPostBackOnFilter="true" HeaderStyle-Width="100px" HeaderText="Nombre" UniqueName="Name">
                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                            <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FirstName" MaxLength="50" FilterControlWidth="80px" CurrentFilterFunction="Contains" ShowFilterIcon="false" ItemStyle-Width="10px" AutoPostBackOnFilter="true" HeaderStyle-Width="100px" HeaderText="Primer Apellido" UniqueName="FirstName">
                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                            <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="LastName" MaxLength="50" FilterControlWidth="80px" CurrentFilterFunction="Contains" ShowFilterIcon="false" ItemStyle-Width="10px" AutoPostBackOnFilter="true" HeaderStyle-Width="100px" HeaderText="Segundo Apellido" UniqueName="LastName">
                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                            <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Email" MaxLength="50" FilterControlWidth="130px" CurrentFilterFunction="Contains" ShowFilterIcon="false" AutoPostBackOnFilter="true" HeaderStyle-Width="150px" HeaderText="Email" UniqueName="Email">
                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                            <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridMaskedColumn DataField="Mobile" MaxLength="50" FilterControlWidth="50px" ShowFilterIcon="false" ItemStyle-Width="10px" AutoPostBackOnFilter="true" HeaderStyle-Width="70px" DataFormatString="{0:####-####}" DisplayMask="####-####" HeaderText="Movil" Mask="####-####" UniqueName="Mobile">
                    </telerik:GridMaskedColumn>
                    <telerik:GridMaskedColumn DataField="Phone" MaxLength="50" FilterControlWidth="50px" ShowFilterIcon="false" ItemStyle-Width="10px" AutoPostBackOnFilter="true" HeaderStyle-Width="70px" DisplayMask="####-####" HeaderText="Teléfono" Mask="####-####" UniqueName="Phone">
                    </telerik:GridMaskedColumn>
                    <telerik:GridCheckBoxColumn DataField="IsActive" CurrentFilterValue="true" FilterControlWidth="50px" CurrentFilterFunction="EqualTo" ShowFilterIcon="false" ItemStyle-Width="40px" AutoPostBackOnFilter="true" HeaderStyle-Width="50px" DataType="System.Boolean" HeaderText="Activo" UniqueName="IsActive">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridBoundColumn DataField="CreationDate" HeaderText="CreationDate" UniqueName="CreationDate" Display="false" ReadOnly="true" ForceExtractValue="Always">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="UserGroupId" Display="false" HeaderText="UserGroupId" UniqueName="UserGroupId" ReadOnly="true" ForceExtractValue="Always">
                    </telerik:GridBoundColumn>
                </Columns>

                <EditFormSettings>
                    <EditColumn InsertText="Agregar" UpdateText="Actualizar" CancelText="Cancelar" ButtonType="ImageButton"></EditColumn>
                </EditFormSettings>

            </MasterTableView>
              <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True"></Scrolling>
                     <Selecting AllowRowSelect="True"></Selecting><ClientEvents OnPopUpShowing="PopUpShowing" />
                </ClientSettings>            
        </telerik:RadGrid>        
        <br />
         <telerik:RadGrid ID="StockFileGrid" runat="server" AllowSorting="true" AutoGenerateColumns="false" CellSpacing="0" GridLines="None" Height="100%" Width="100%" GroupingSettings-CaseSensitive="false" OnDeleteCommand="StockFileGrid_DeleteCommand" OnNeedDataSource="StockFileGrid_NeedDataSource" >
                <MasterTableView EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-CaptionFormatString="Modo Edición" CommandItemDisplay="TopAndBottom" NoMasterRecordsText="No hay registros" AllowFilteringByColumn="true" TableLayout="Auto">
                    <CommandItemTemplate>
                        <div style="padding: 5px 5px;"> Lista de Archivos Asociados: 
                             <asp:LinkButton ID="lbAdd" runat="server"  OnClientClick="OpenStockFileSearch()" Visible='<%# !StockFileGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/text-plus-icon.png"/>Asociar archivos</asp:LinkButton>
                             <asp:LinkButton ID="lbClearFilters" runat="server" OnClick="lbClearFiltersStockFileGrid_Click"  Visible='<%# !StockFileGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/mixx-icon.png"/>Limpiar Filtros</asp:LinkButton>                                                                               
                            <asp:LinkButton ID="lbShowError" runat="server" OnClick="lbShowError_Click" Visible='<%# HiddenFieldError.Value == string.Empty ? false : true %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/bug-icon.png"/>Error técnivo</asp:LinkButton>   
                        </div>                        
                    </CommandItemTemplate>
                    <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Nuevo archivo" RefreshText="Actualizar"></CommandItemSettings>

                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>

                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>

                    <Columns>                        
                        <telerik:GridButtonColumn  ConfirmText="¿Desea eliminar el registro?" Text="Eliminar" ConfirmDialogType="RadWindow" ConfirmDialogHeight="120" ConfirmDialogWidth="270" ConfirmTitle="Eliminar" ButtonType="ImageButton" CommandName="Delete" HeaderStyle-Width="25px"/>                                                     
                        <telerik:GridBoundColumn DataField="CompanyId" FilterControlAltText="Filter Imei column" HeaderText="CompanyId" UniqueName="CompanyId" Display="false"  ReadOnly="true" ForceExtractValue="Always">                            
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="StockFileId" FilterControlAltText="Filter Imei column" HeaderText="StockFileId" UniqueName="StockFileId" ReadOnly="true" Display="false" ForceExtractValue="Always">                            
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Username" FilterControlAltText="Filter Username column" HeaderText="Username" UniqueName="Username" ReadOnly="true" Display="false" ForceExtractValue="Always">                            
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CompanyIdStockFileIdSource.Name" FilterControlAltText="Filter Name column" HeaderText="Nombre" UniqueName="Name" MaxLength="50"
                            FilterControlWidth="300px" CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="320px" AutoPostBackOnFilter="true">                          
                        </telerik:GridBoundColumn>
                         <telerik:GridBoundColumn HeaderText="Archivo" UniqueName="Filename" DataField="CompanyIdStockFileIdSource.Filename" ForceExtractValue="Always"
                             FilterControlWidth="200px" CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="220px" AutoPostBackOnFilter="true">                              
                            </telerik:GridBoundColumn>
                        <telerik:GridDropDownColumn DataField="CompanyIdStockFileIdSource.StockFileTypeOfFileId" DataType="System.Int32" DataSourceID="sdsFileType" FilterControlAltText="Filter GPSTypeID column" HeaderText="Tipo" ListTextField="Name" ListValueField="StockFileTypeOfFileId" UniqueName="StockFileTypeOfFileId">
                            <FilterTemplate>
                                <telerik:RadComboBox ID="cmbFileType" DataSourceID="sdsFileType" DataTextField="Name" DataValueField="StockFileTypeOfFileId"  Width="100px"
                                    AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("StockFileTypeOfFileId").CurrentFilterValue %>'
                                    runat="server" OnClientSelectedIndexChanged="FileTypeIdIndexChanged" Sort="Ascending">
                                    <Items>
                                        <telerik:RadComboBoxItem Text="Todos" Value="" />
                                    </Items>
                                </telerik:RadComboBox>
                                <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
                                    <script type="text/javascript">
                                        function FileTypeIdIndexChanged(sender, args) {                                            
                                            var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                            tableView.filter("StockFileTypeOfFileId", args.get_item().get_value(), "EqualTo");
                                        }
                                    </script>
                                </telerik:RadScriptBlock>
                            </FilterTemplate>
                        </telerik:GridDropDownColumn>                       
                    </Columns>

                    <EditFormSettings>
                        <EditColumn InsertText="Agregar" UpdateText="Actualizar" CancelText="Cancelar" ButtonType="ImageButton"></EditColumn>
                    </EditFormSettings>
                </MasterTableView>
                <ClientSettings EnableRowHoverStyle="true">
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True"></Scrolling>
                     <Selecting AllowRowSelect="True"></Selecting><ClientEvents OnPopUpShowing="PopUpShowing" />
                </ClientSettings>
                <FilterMenu EnableImageSprites="False"></FilterMenu>
            </telerik:RadGrid>      
        <asp:SqlDataSource ID="sdsFileType" SelectCommandType="StoredProcedure" SelectCommand="StockFilesTypeOfFile_Get_List" runat="server"></asp:SqlDataSource>   
        <uc1:StockFileSearch ID="StockFileSearch1" runat="server" IsClearGridAfterClose="True" IsMultipleSelects="True" OnOnAcceptEvent="StockFileSearch1_OnAcceptEvent" OnOnCancelEvent="StockFileSearch1_OnCancelEvent" />     
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
    </form>
</body>
</html>
